/**
 * ziyi
 */

 module ziyi{
    export class Main extends eui.UILayer {
        protected createChildren(): void {
            super.createChildren();
            //注入自定义的素材解析器
            let assetAdapter = new AssetAdapter();
            egret.registerImplementation("eui.IAssetAdapter", assetAdapter);
            egret.registerImplementation("eui.IThemeAdapter", new ThemeAdapter());
            this.runGame().catch(e => {
                console.log(e);
            })
        }
        private async runGame() {
            await this.loadResource()
            this.createGameScene();
            const result = await RES.getResAsync("description_json")
        }
        private async loadResource() {
            try {
                await RES.loadConfig("resource/default.res.json", "resource/");
                await this.loadTheme();
                await RES.loadGroup("preload");
                await this.loadScene();
            }
            catch (e) {
                console.error(e);
            }
        }
        private loadTheme() {
            return new Promise((resolve, reject) => {
                // load skin theme configuration file, you can manually modify the file. And replace the default skin.
                //加载皮肤主题配置文件,可以手动修改这个文件。替换默认皮肤。
                let theme = new eui.Theme("resource/default.thm.json", this.stage);
                theme.addEventListener(eui.UIEvent.COMPLETE, () => {
                    resolve();
                }, this);
            })
        }
        private loadScene(){
            this.scene=new Scene();
        }
        private scene:Scene;
        protected createGameScene(): void {
            this.stage.addChild(this.scene);
        }
    }
 }
window["ziyi"]=ziyi;
window["Main"]=ziyi.Main;